package com.augurit.gzcgwsp.rqqyjyxk.service.impl;

import java.util.HashMap;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkPzrqgyzdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkQysbclmc;
import com.augurit.gzcgwsp.rqqyjyxk.dao.YwRqQyjyxkFinalPzrqgyzdjbDao;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalPzrqgyzdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalQysbclmc;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRypbqk;
import com.augurit.gzcgwsp.rqqyjyxk.service.IYwRqQyjyxkFinalPzrqgyzdjbService;

/**
 *最终数据 广州市燃气经营许可证许可审批------七、瓶装燃气供应站登记表
 * @author 张军
 *
 */
@Service("pzrqgyService")
@Transactional
public class YwRqQyjyxkFinalPzrqgyzdjbServiceImpl implements IYwRqQyjyxkFinalPzrqgyzdjbService {
	@Autowired
	private YwRqQyjyxkFinalPzrqgyzdjbDao pzrqgyDao;
	/**
	 * 保存 瓶装燃气供应站登记表
	 * @param ywRqQyjyxkPzrqgyzdjb
	 */
	public Long save(YwRqQyjyxkFinalPzrqgyzdjb finalentity) {
            return pzrqgyDao.saveEntity(finalentity);
        
	}

	

	
    public List<YwRqQyjyxkFinalPzrqgyzdjb> getListByQyId(Long qyid){
        String hql = "from "+YwRqQyjyxkFinalPzrqgyzdjb.class.getName()+" t where t.qyid='" + qyid + "'";
        List<YwRqQyjyxkFinalPzrqgyzdjb> entityList = pzrqgyDao.find(hql);
        return entityList;
    }




    public YwRqQyjyxkFinalPzrqgyzdjb getZdInfo(String id) {
        YwRqQyjyxkFinalPzrqgyzdjb entity=null;
        if(StringUtils.isNotBlank(id)){
            String hql = "from "+YwRqQyjyxkFinalPzrqgyzdjb.class.getName()+" t where t.id='" + Long.valueOf(id) + "'";
            List<YwRqQyjyxkFinalPzrqgyzdjb> entityList = pzrqgyDao.find(hql);
            entity=entityList.get(0);
        }
        return entity;
    }




    public List<YwRqQyjyxkFinalRypbqk> getDatasByzdid(Long id) {
        String hql = "from "+YwRqQyjyxkFinalRypbqk.class.getName()+" t where t.gyzid='" + Long.valueOf(id) + "'";
        List<YwRqQyjyxkFinalRypbqk> entityList = pzrqgyDao.find(hql);
        return entityList;
    }




	public Page getPage(String acceptNo, Page page, Long qyid, String type) {
		 String  hql=" from "+ YwRqQyjyxkPzrqgyzdjb.class.getName()+" where acceptNo='"+acceptNo+"'";
		    if("2".equals(type)){
		    	hql=" from "+ YwRqQyjyxkFinalPzrqgyzdjb.class.getName()+" where qyid='"+qyid+"'";
		    	
		    }
			 return pzrqgyDao.findPage(page, hql, new HashMap());
	}

	/*
	 * (non-Javadoc)
	 * @see com.augurit.gzcgwsp.rqqyjyxk.service.IYwRqQyjyxkFinalPzrqgyzdjbService#getClsbPage(java.lang.String, org.springside.modules.orm.Page, java.lang.Long, java.lang.String)
	 */
	public Page getClsbPage(String acceptNo, Page page, Long qyid, String type) {
		 String  hql=" from "+ YwRqQyjyxkQysbclmc.class.getName()+" where acceptNo='"+acceptNo+"'";
		    if("2".equals(type)){
		    	hql=" from "+ YwRqQyjyxkFinalQysbclmc.class.getName()+" where qyid='"+qyid+"'";
		    	
		    }
			 return pzrqgyDao.findPage(page, hql, new HashMap());
	}

}
